/* 
 *  Copyright (c) 2011—2013 Panguso.com. All rights reserved. 
 *  File Name:  MapReduceTerminal.java                                      
 *  File Contents Outline :  Mapreduce命令                  
 *  File  Create Date:   2012年7月30日
 *  File Version#: Revision#: #1                  
 *  File  Latest Modify Date : 2013年1月16日
 *  File Author :  bachuan@panguso.com
 */
package cn.edu.thu.log.terminal;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
import java.io.*;
/**
 *
 * @author fenyo
 */
public class MapReduceTerminal {
    private static String hadooppath = "/data/bcpdm/hadoop-0.20.2";  
    public static void xes_convertor(String jarfile , String inputfilepath , String outputfilepath) throws Exception {
        String[] shellcommand = new String[4];
        shellcommand[0]="/bin/sh";
        shellcommand[1]="-c";
        shellcommand[2]="cd "+hadooppath;
        shellcommand[3]="bin/hadoop jar "+jarfile+" "+inputfilepath+" "+outputfilepath;
        Process process;
        process = Runtime.getRuntime().exec(shellcommand,null,null);
         InputStreamReader ir = new InputStreamReader(process  
                .getInputStream());  
        LineNumberReader input = new LineNumberReader(ir);  
        process.waitFor();       
        List<String> strList = new ArrayList<String>(); 
        String line;
        while ((line = input.readLine()) != null){  
            strList.add(line);  
        }  
        for( int i = 0 ; i < strList.size(); i ++ ){
//                System.out.println(strList.get(i));
        }
        
    }
    public static void main(String[] args) throws Exception{
        MapReduceTerminal.xes_convertor("Test_reduce15.jar", "/tmp/input_big/input_big", "/tmp/outputPM_big_big_big");
    }
}
